<template>
  <div>
    <etable ref="eTable" :columns="columns" :tools="['refresh','export']"></etable>
  </div>
</template>

<script>
import dayjs from 'dayjs'
import etable from '@/components/easy-table/easy-table.vue'

export default {
  name: 'error_logger_page',
  components: {
    etable
  },
  data () {
    return {
      url: 'sys/log/error/list?',
      columns: [
        {
          type: 'index',
          title: '序号',
          align: 'center',
          width: 100
        },
        {
          key: 'type',
          title: '类型',
          width: 100,
          render: (h, params, vm) => {
            return h('div', [
              h('Icon', {
                props: {
                  type: params.row.type === 'ajax' ? 'md-link' : 'md-code-working',
                  size: 16,
                  color: '#000000'
                }
              })
            ])
          }
        },
        {
          key: 'code',
          title: '编码',
          render: (h, params, vm) => {
            return h('span', params.row.code === 0 ? '-' : row.code)
          }
        },
        {
          key: 'mes',
          title: '信息'
        },
        {
          key: 'url',
          title: 'URL'
        },
        {
          key: 'time',
          title: '时间',
          alias: 't',
          render: (h, params, vm) => {
            return h('span', dayjs(params.row.time).format('YYYY-MM-DD HH:mm:ss'))
          },
          sortable: true
        }
      ]
    }
  },
  computed: {
  },
  methods: {
    exportData () {
      this.$refs.table.exportCsv({
        filename: '错误日志.csv'
      })
    }
  },
  mounted () {
    this.$refs['eTable'].init(this.url)
  }
}
</script>

<style>

</style>
